import { network } from "../../utils/network.js";
Page({

  /**
   * 页面的初始数据
   */
  data: {
    d:"song",
    uid: 59180335,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    wx.showLoading({
      title: '加载中...',
    })

    var that=this;
    wx.request({
      url: 'http://neteasemusic.leanapp.cn/user/detail',
      data: {
        uid: getApp().globalData.uid
      },
      success: function (res) {
        that.setData({
          avatarurl: res.data.profile.avatarUrl
        })
      }
    })
    wx.request({
      url: 'http://neteasemusic.leanapp.cn/personalized/privatecontent',
      success: function (res) {
        console.log(res.data.result)
        that.setData({
          ad: res.data.result
        })
      }
    })
    wx.request({
      url: 'http://neteasemusic.leanapp.cn/personalized/newsong',
      success: function (res) {
        that.setData({
          songs: res.data.result
        })
      }
    })
    wx.request({
      url: 'http://neteasemusic.leanapp.cn/personalized?limit=30',
      success: function (res) {
        that.setData({
          sheet: res.data.result
        })
      }
    })
    wx.request({
      url: 'http://neteasemusic.leanapp.cn/top/artists?offset=0&limit=30',
      success: function (res) {
        that.setData({
          artists: res.data.artists
        })
      }
    })

    wx.request({
      url: 'http://neteasemusic.leanapp.cn/top/album?offset=0&limit=30',
      success: function(res) {
        that.setData({
          albums:res.data.albums
        })
        console.log(res.data.albums)
      },
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    wx.hideLoading()
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    var musicid = getApp().globalData.musicid
    console.log(getApp().globalData.musicid)
    that.setData({
      musicid: musicid,
      isFM: getApp().globalData.isFM
    })
    network.getDetail({
      id: musicid,
      success: function (song) {
        that.setData({
          song: song
        })
      },
    })
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})